package com.bokee.archerwq.lab.socket.serverviapool;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

import com.bokee.archerwq.lab.thread.mythreadpool.Task;

public class MyTask implements Task {

	public static long threadCount;

	private Socket socket;

	public MyTask(Socket socket) {
		this.socket = socket;
		threadCount++;
	}

	public void run() {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					socket.getInputStream()));

			String message = null;
			while (!(message = br.readLine()).equalsIgnoreCase("bye")) {
				System.out.println(message);
			}
			socket.close();
			System.out.println("Connection closed!");

			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
